<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="addAppTitle">
	<h2>
		<font size="2">为${keywords.keywords }续费 </font>
		<c:if test="${account != null }">
			<font color="red" size="2"> 【当前账户余额：￥ <span id="accountspan">${ account.money}</span>】
			</font>
		</c:if>
	</h2>
</div>
<div class="message"></div>
<div class="formdiv">
		<ul>
			<li><a>客户名称：</a><input id="customname" class="customname"
				value="${ keywords.customname}" type="text" readonly="readonly" /></li>
			<li><a>关键词：</a><input id="keyword" class="keyword" type="text"
				value="${keywords.keywords }" readonly="readonly" /> <span
				id="keywordtip" class="keywordtip"></span></li>
			<li><a>服务类别：</a> <select id="xufei_servicetype">
					<option value=''>--请选择--</option>
					<c:forEach items="${serviceType}" var="type">
						<option value="${type.id}"
							<c:if test="${ keywords.producttype == type.id}">selected="selected"</c:if>>
							${type.configtypename}</option>
					</c:forEach>
			</select></li>
			<li><a>服务年限：</a> <select id="xufei_serviceyears">
					<option value="" selected="selected">--请选择--</option>
					<c:forEach var="i" begin="1" end="${maxyears.configvalue}" step="1">
						<option value="${i}">${i}</option>
					</c:forEach>
					<c:forEach items="${youhuitype}" var="type">
						<option value="youhui_${type.id}">${type.configtypename }</option>
					</c:forEach>
			</select></li>
			<li><a>价格：</a><input class="price" id="xufei_price" type="text"
				readonly="readonly" /></li>
		</ul>
</div>
<link href="static/css/xufei.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
	function checksubmit(kid) {
		var flag = true;
		var serviceType = $("#xufei_servicetype").val();
		var years = $("#xufei_serviceyears").val();
		if (servicetype == null || servicetype == "") {
			flag = false;
			$.messager.alert('提示', "对不起，您还没有选择服务类型。", 'error');
			$("#xufei_servicetype").focus();
		} else if (years == null || years == "") {
			flag = false;
			$.messager.alert('提示', "对不起，您还没有选择服务年限。", 'error');
			$("#xufei_serviceyears").focus();
		} else if (kid <= 0) {
			flag = false;
			$.messager.alert('提示', "对不起，数据不完整，您不能进行续费操作。", 'error');
		}
		return flag;
	}
	//选择改变时自动计算价格
	$().ready(function() {
		$("#xufei_servicetype").change(function() {
			console.info("xufei....");
			xufei_jisuan();
		});
		$("#xufei_serviceyears").change(function() {
			console.info("xufei....years");
			xufei_jisuan();
		});
	});
	
	//计算价格
	function xufei_jisuan() {
		var servicetype = $("#xufei_servicetype").val();
		var years = $("#xufei_serviceyears").val();
		if (servicetype == null || servicetype == "") {
			$.messager.alert('提示', "对不起，您还没有选择服务类型。", 'error');
			$("#xufei_servicetype").focus();
		} else if (years == null || years == "") {
			$.messager.alert('提示', "对不起，您还没有选择服务年限。", 'error');
			$("#xufei_serviceyears").focus();
		} else {
			$.post('keywords/price', {
				p : servicetype + "-" + years
			}, function(result) {
				if ("fail" == result) {
					$.messager.alert('提示', "对不起，您申请的续费在计算价格的时候出现异常，请重试。", 'error');
				} else {
					$("#xufei_price").val(result);
				}
			}, 'text');
		}
	}
</script>
